/* 3DGo Game
 * Copyright (C) 2008 Roman Hwang, Eugene Melnichek

 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation - version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef _GTPINTERFACE_H_
#define _GTPINTERFACE_H_

#include "..\PhantomRunnerLib\PhantomRunner.h"
#include "GTPMove.h"

#include <string>

/* 
Class provides interface to GTP client.
Singleton class.
*/
class GTPInterface
{

private:

	int m_boardSize;
	PhantomRunner m_runner;
	bool _isLastMovePass;

	GTPInterface();

private:

	/* Cleans array of chars from unnecessary symbols */
	void CleanBoard(char* board);

	/* Convert from Color to string */
	inline const char* ColorToChar(Color _color) const
	{
		return ( _color == WHITE ) ? "white" : "black";
	}
	
public:
	
	/* Get instance of class */
	static GTPInterface* GetInstance();

	/* Destructor */
	~GTPInterface();

	/* Set or get boardsize */
	void SetBoardSize(int _boardSize);
	int GetBoardSize() const;

	/* Get board in string form */
	std::string GetBoard();

	/* 
	Make move. 
	Used by human player.
	*/
	bool MakeMove(const GTPMove& _move);

	/* Generate move for specified color */
	bool GenerateMove(Color _color);

	void Quit();

	/* */
	bool IsLastMovePass() const;

	std::string GetFinalScore();

};

#endif // _GTPINTERFACE_H_
